# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=orc
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.4.34
pkgrel=1
pkgdesc="The Oild Runtime Compiler (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://gstreamer.freedesktop.org/projects/orc.html"
license=("custom")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja")
source=("https://gstreamer.freedesktop.org/src/orc/${_realname}-${pkgver}.tar.xz")
sha256sums=('8f47abb3f097171e44eb807adcdabd860fba2effd37d8d3c4fbd5f341cadd41f')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dauto_features=enabled \
    -Dgtk_doc=disabled \
    ../${_realname}-${pkgver}

  meson compile
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}" meson install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
